Cat and Dog problem
A simple geometric solution
A more general solution
Dot product \(\vec a\vec b=a_xb_x+a_yb_y=|\vec a||\vec b|\cos(\theta)\)
Exercise:
\(g(x)=<C_+-C_-,X-C>=<C_+,X>-<C_-,X>-<C_+,C>+<C_-,C>\);
\(<C_+,X>=<\frac1{n_{+}}\sum\limits_{l\in I_+}^nx_i,x>\);
\(<C_-,X>=<\frac1{n_{-}}\sum\limits_{l\in I_-}^nx_i,x>\);
\(<C_+,C>=<C_+,\frac12C_+>+<C_+,\frac12C_->=\frac1{2n_{+}^2}\sum\limits_{(i,j)\in I_{+}}<x_i,x_j>+\frac12<C_+,C_->\)
\(<C_-,C>=<C_-,\frac12C_+>+<C_-,\frac12C_->=\frac12<C_+,C_->+\frac1{2n_{-}^2}\sum\limits_{(i,j)\in I_{-}}<x_i,x_j>\)
\(g(x)=\sum_{l=1}^n\alpha_i<x_i,x>+b\),
\(b=\frac12\left[\frac1{n_{-}^2}\sum\limits_{(i,j)\in I_{-}}<x_i,x_j>-\frac1{n_{+}^2}\sum\limits_{(i,j)\in I_{+}}<x_i,x_j>\right]\)
\(\alpha_i=\begin{cases}\frac1{n_{+}}&y_i=+1\\-\frac1{n_{-}}&y_i=-1\end{cases}\)
Define the train and test sets
Define a kernel function and classifier
define a 3D grid
Plot the test and 3D grid
Another kernel function and another way of computing the classifier
Define a grid
Plot the test and grid
## [1] 0
Error rate = 0%
# # #f